﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
using System.Collections.Generic;
namespace WPFExcelReport
{
    public partial class TSAM06
    {
        public TSAM06()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VAMEINST();
            DataContext = MV;
            InitializeComponent();
        }

        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);              
        } 

       
        public override void OnEXAUFChg(string am)
        {
            TBMain.Clear();
            if (EXAUF.Length < 11)
                return;
          
            dwData = TMV.TBMain.NewRow();
            KRS = am.Substring(0, 2);
            LFD = am.Substring(2, 4);
            dwData["AMEMANDANT"] = app.Mandant;
            dwData["AMENRKRS"] = " AND AMENRKRS='" + EXAUF.Substring(0, 2) + "'";
            dwData["AMELFDNR"] = " AND AMELFDNR='" + EXAUF.Substring(2, 4) + "'";
            dwData["AMEPOS"] = " AND AMEPOS='" + EXAUF.Substring(6, 2) + "'";
            dwData["AMEMODNR"] = " AND AMEMODNR='" + EXAUF.Substring(8, 3) + "'";
            SResult = TMV.QAME02(dwData);
            MergeData(SResult, false);
            base.OnEXAUFChg(am);
        }
        public override void LOADBYAUF()
        {
            Locate("KEY", ORDERNUM);
            base.LOADBYAUF();
        }

        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            if (IsManage)
            {
                OnEXAUFChg(EXAUF);
            }
            base.ManageCommand(sender, e);
        } 
    }

}
